const urls = [{
    description: "描述",
    high: "69.90",
    id: 12,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "https://www.douyin.com/aweme/v1/play/?video_id=v0d00fg10000cj1lq4jc77u0ng6s1gt0&line=0&file_id=bed51c00899b458cbc5d8280147c22a1&sign=7749aec7bd62a3760065f60e40fc1867&is_play_url=1&source=PackSourceEnum_PUBLISH",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 11,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "https://v13-traffic-a.douyinvod.com/e89f2a8f6c96d3172687d1a3195a7b41/67dd3c67/video/tos/cn/tos-cn-ve-15c001-alinc2/ooe8lnrARACvNpAAoAfDsLXIsgb9gN8AkTBcEb/?a=1128&ch=0&cr=0&dr=0&er=0&cd=0%7C0%7C0%7C0&cv=1&br=2174&bt=2174&cs=0&ds=4&ft=ahz4iQQqUYqfJEZao0OW_EklpPiXCLKqoVJE0I.CaCPD-Ipz&mime_type=video_mp4&qs=0&rc=ZGU2OTk2NWc1ZDdlZTxpNUBpanQzb2Q6ZnV2bDMzNGkzM0BiMDMuMmI0NjIxNWEzYS41YSM1MmwucjRvX2tgLS1kLS9zcw%3D%3D&btag=80000e00088000&cquery=100y&dy_q=1742548560&feature_id=f0150a16a324336cda5d6dd0b69ed299&l=2025032117160027379E5807266D066CE1",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 13,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/group/video/3a07a5f0b1540db174c74442eaf53afa.mp4",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 14,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/group/video/3a07a5f0b1540db174c74442eaf53afa.mp4",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 15,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/group/video/3a07a5f0b1540db174c74442eaf53afa.mp4",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 16,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/group/video/3a07a5f0b1540db174c74442eaf53afa.mp4",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 17,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/group/video/3a07a5f0b1540db174c74442eaf53afa.mp4",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 18,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/group/video/3a07a5f0b1540db174c74442eaf53afa.mp4",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 19,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/group/video/3a07a5f0b1540db174c74442eaf53afa.mp4",
    view_num: 13
  },
  {
    description: "描述",
    high: "69.90",
    id: 20,
    image: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/admin/goods/20240624/fc211282-5e29-4d2c-9613-2ac348d922be.jpg",
    join_num: 0,
    low_price: "0.01",
    name: "测试预开团",
    video_url: "http://haixingmama-dev.oss-cn-shenzhen.aliyuncs.com/group/video/3a07a5f0b1540db174c74442eaf53afa.mp4",
    view_num: 13
  },
]
// const videoList = urls
const app = getApp()
// const {
//   shareImg
// } = require('../../http/api/home')
// const {
//   videoListGet,personalVedioPrompt
// } = require('../../http/api/group')
Page({
  /**
   * 页面的初始数据
   */
  data: {
    id: 0,
    buttons: [{
      text: '取消'
    }, {
      text: '确认'
    }],
    videoList: [],
    current_index: 0,
    moreFlag: true,
    page: 2,
    page_size: 10,
    gid: 0,
    guideShow: false
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    const {
      id
    } = options
    this.setData({
      id
    })
    // this.getData()
    let that = this
    if (app.globalData.token) {
      that.getData()
    } else {
      app.getloginCallback = (v) => {
        if (v) {
          that.getData()
        }
      }
    }
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },
  goBack() {
    wx.navigateBack({
      delta: -1
    })
  },
  async getData() {
    if (app.globalData.is_video_prompt == 0) {
      this.setData({
        guideShow: true
      })
      app.globalData.is_video_prompt = 1
      personalVedioPrompt()
    }
    const resV = await videoListGet({
      group_buy_id: this.data.id,
      page: 1,
      page_size: 10
    })
    const _v = resV.data.data
    //  if(_v.length<10){
    //    const _len = 10 - _v.length
    //     for (let index = 0; index < _len; index++) {
    //       _v.push(_v[index])
    //     }
    //  }
    this.setData({
      videoList: _v
    })
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },
  onPlay(e) {},
  onPause() {},
  onTimeUpdate() {},
  onEnded() {},
  onError() {},
  onWaiting() {},
  onProgress() {},
  onLoadedMetaData(e) {},
  onPlayCurrent(e) {
    console.log(e.detail);
    this.setData({
      gid: e.detail
    })
  },
  async onUpdataVideo(e) {
    // if (!this.data.moreFlag) {
    //   return
    // }
    // if (this.data.page === 1) {
    //   this.setData({
    //     videoList: []
    //   })
    // }
    const resGoods = await videoListGet({
      page: this.data.page,
      page_size: this.data.page_size
    })
    console.log(resGoods);
    const _v = resGoods.data.data
    if (_v.length < 10) {
      const _len = 10 - _v.length
      for (let index = 0; index < _len; index++) {
        _v.push(_v[index])
      }
    }
    let goodsData = [...this.data.videoList, ..._v]
    this.setData({
      videoList: goodsData,
      page: this.data.page + 1
    })
    return
    if (resGoods.data.data.data.length < this.data.page_size) {
      this.setData({
        videoList: goodsData,
        moreFlag: false
      })
    } else {

    }


    // let videoList = this.data.videoList;
    // if (videoList.length >= 30) {
    //   console.log('已经加到顶了');
    //   return;
    // }
    // // 模拟数据请求

    // setTimeout(()=>{
    //   let url = 'https://prod-streaming-video-msn-com.akamaized.net/a8c412fa-f696-4ff2-9c76-e8ed9cdffe0f/604a87fc-e7bc-463e-8d56-cde7e661d690.mp4';
    //   for(let i = 0; i < 10; i++) {
    //     let time = new Date();
    //     videoList.push({id: time.getTime(), url});
    //   }
    //   this.setData({videoList});
    // }, 1000)
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  async onShareAppMessage(e) {
    console.log(e);
    console.log(this.data.gid);
    // const _data = this.data.videoList.find(v=>v.id == this.data.gid)
    const res = await shareImg({
      type: 5,
      group_buy_id: this.data.gid
    })
    const share_code = wx.getStorageSync('USER_INFO').share_code
    return {
      title: res.data.data.name,
      path: '/pages/home/index?videoid=' + this.data.gid + '&share_code=' + share_code,
      imageUrl: res.data.data.url
    }
  }
})